package com.homework;

import java.util.Scanner;
public class Worker {
private String name;
private String year;
    public  Worker(){}
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getYear() {
        return year;
    }

    public void setYear(String year) {
        this.year = year;
    }
    public void show(){
        System.out.println(" 该工人对象的属性信息如下:");
        System.out.println(" 姓名:" + name);
        System.out.println(" 工龄:" + year);
    }
}

class TestWorker{
     public static void main(String[] args) {
         Scanner sc = new Scanner(System.in);
         System.out.println("请录入工人姓名:");
         String name =sc.nextLine();
         System.out.println("请录入工人工龄:");
         String year = sc.nextLine();
         Worker w = new Worker();
         w.setName(name);
         w.setYear(year);
         w.show();
     }
}
